
<?php
	include_once("functions_db.php");
	include 'headermenu.php';
	
?>

<html>
<head>
</head>
<body>
				<div id="doc" class="yui-t7">
				<div id="bd" role="main">
				<div class="yui-gc">
				<link rel="stylesheet" href="yui.css" type="text/css">
	<?php
	
		dbconn();
			$dbcon=dbConn();
			$message = "";
			$passwordMessage = "";
			$firstnameMessage = "";
			$lastnameMessage = "";
			
			$pass		= null;
			
			$account 	= null;
			$mail		= null;
			
			if(ISSET($_GET["account"]) && ISSET($_GET["mail"]))
			{	
				$account 	= $_GET["account"];
				$mail		= $_GET["mail"];
			}			
			
			if(ISSET($_POST["Enter"]))
			{
				$account 	= $_POST["account"];
				$mail		= $_POST["mail"];
				md5($_POST["password"]); 
				
				if($_POST["password"] != null && $_POST["first_name"] != null && $_POST["last_name"] != null)
				{
					$result = mysql_query("UPDATE users SET password='".md5($_POST["password"])."',first_name='".$_POST['first_name']."',last_name='".$_POST['last_name']."' 
							WHERE account='$account' AND mail='$mail';")or die(mysql_error());
							
					echo "<script type =\"text/javascript\">window.location.href=\"logIn.php\";</script>";
	
					exit();		
				}
				else
				{					
					//$temp = 1;
					if(empty($_POST["password"]))
					{
						$passwordMessage = "Password is required!";			
					}
					if(empty($_POST["first_name"]))
					{
						$firstnameMessage = "First Name is required!";			
					}
					if(empty($_POST["last_name"]))
					{
						$lastnameMessage = "Last name is required!";			
					}
				}
			}
	?>
			<form name="RegistrationUser" method="POST" action="RegistrationUser.php">			
				
				<input type="hidden" name="mail" id="mail" value="<?php echo $mail; ?>" />
				<input type="hidden" name="account" id="account" value="<?php echo $account; ?>" />
		
				<p>
				Password <font color="#ff0000">*</font><br />
				<input name="password" id="password" type="password" value="">&nbsp;<?php echo $passwordMessage ?>
				</p>
		
				<p>
				First name <font color="#ff0000">*</font><br />
				<input name="first_name" id="first_name" type="text" value="<?php echo $first_name ?>">&nbsp;<?php echo $firstnameMessage ?>
				</p>
				
				<p>
				Last name <font color="#ff0000">*</font><br />
				<input name="last_name" id="last_name" type="text" value="<?php echo $last_name ?>">&nbsp;<?php echo $lastnameMessage ?>
				</p>

				<input type="submit" name="Enter" id="Enter" value="Enter" />
			

			</form>
	</div>
	</div>
	</div>
</body>
</html>